# 
# blog_base_controller.rb
# 
# Created on 2007-10-12, 20:15:39
# 
# To change this template, choose Tools | Templates
# and open the template in the editor.
 

class Base::BlogBaseController<ApplicationController

  
  def index
    @blogs=Blog.paginate_list(params[:page])
  end
  
  def view
    @blog=Blog.find(params[:id])
    @comment=Comment.new
    @comment.resource_id=@blog.id
    @comment.resource_type='Blog'
    @comments=Comment.paginate_by('blog', @blog.id, params[:page])
  end
  
  def count_and_view
    @blog=Blog.find(params[:id])
    @blog.view_count+=1
    if @blog.save
      redirect_to :action=>:view, :id=>@blog.id
    end
  end
  
  def list_in_category
    @blogs=Blog.paginate_category(params[:category_id], params[:page])
    render :partial=>'blog/list', :object=>@blogs, :layout=>'blog_public'
  end
  
  def list_comments
    @blog=Blog.find(params[:blog_id])
    @comments=Comment.paginate_by('blog', @blog.id, params[:page])
  end
  
end
